package io.renren.source;/**
 * @Description:
 * @author: 阿海
 * @create: 2020-04-07 19:23
 */

import lombok.AllArgsConstructor;
import lombok.Data;
import org.apache.http.HttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description:
 * @author: 阿海
 * @create: 2020-04-07 19:23
 */
public class HashMapTest {

    public static void main(String[] args) {

        String url = "http://stg1-gws-mall.daikuan.360.cn/api/tuia/callback/gateway.do";
        MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();

        Map<String, Object> paramMap = new HashMap<>(8);
        paramMap.put("timestamp", "1586346808065");
        paramMap.put("appKey","3REe4tmpYzJWuiUxzbVGdBWkj57E");
        paramMap.put("taskType", "add");
        paramMap.put("remark", "null");
        paramMap.put("retryTimes","2");
        postParameters.setAll(paramMap);
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
//        headers.add("Content-Type", "application/x-www-form-urlencoded");
        // 当时对接文档不完善，导致360是application/json。需要让花生修改下文档
        HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(postParameters, headers);

        CloseableHttpClient client = HttpClientBuilder.create().build();

        RestTemplate restTemplate = new RestTemplate();
        String s = restTemplate.postForObject(url,
                httpEntity, String.class);
        System.out.println(s);
    }


    @Data
    @AllArgsConstructor
    static class Student {
        private int age;

        @Override
        public final int hashCode() {
            return age/10;
        }
    }
}

